# Maintainer: David Runge <dvzrv@archlinux.org>

pkgname=cpputest
pkgver=4.0
pkgrel=4
pkgdesc="Unit testing and mocking framework for C/C++"
arch=(loong64 x86_64)
url="https://github.com/cpputest/cpputest"
license=(BSD)
makedepends=(cmake)
options=(
  !strip
  staticlibs
)
source=($pkgname-$pkgver.tar.gz::$url/archive/refs/tags/v$pkgver.tar.gz)
sha512sums=('5f7d6f9e34a462b35a0161a7486fd56074f5b07f92d029a3c57741c72df7bbc6ea4f98b1e57e9c500ad6d57c303d222afe523d59ec943f4461f67ce5be74dd77')
b2sums=('b44698158e5d0091e64ec3ac1f8009cc8f23286155e9314ae232bd6991425338da7c0ad5a3e9682d086af6aa86df5c56d62026ab4e28749563e726744ecf86ca')

build() {
  local cmake_options=(
    -B build
    -D CMAKE_BUILD_TYPE=None
    -D CMAKE_INSTALL_PREFIX=/usr
    -D LONGLONG=ON
    -D C++11=ON
    -S $pkgname-$pkgver
    -W no-dev
  )

  cmake "${cmake_options[@]}"
  cmake --build build
}

check() {
  ctest --test-dir build --output-on-failure
}

package() {
  DESTDIR="$pkgdir" cmake --install build
  install -vDm 644 $pkgname-$pkgver/COPYING -t "$pkgdir/usr/share/licenses/$pkgname/"
}
